import { ADD_NUMBER, SUB_NUMBER, CHANGE_NAME, CHANGE_BANNER } from "./constants"

const initialState = {
  name: "jay",
  counter: 100,
  banner: []
}

function reducer(state = initialState, action) {
  switch (action.type) {
    case CHANGE_NAME:
      return { ...state, name:action.name } 

    case CHANGE_BANNER:
      return { ...state, banner:action.banner } 

    case ADD_NUMBER:
      return { ...state, counter: state.counter + action.num}
    
    case SUB_NUMBER:
      return { ...state, counter: state.counter - action.num}

    default:
      return state
  }
}

export { reducer }